package com.company;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/22 18:54
 */
public class Main43 {

    public static int compareNumber(String s1,String s2) {
        int[] maxVuales01 = judgeNumber02(s1);
        int[] maxVuales02 = judgeNumber02(s2);

        int maxValue01 = Math.max(maxVuales01[0],maxVuales01[1]);
        int maxValue02 = Math.max(maxVuales02[0],maxVuales02[1]);

        if (maxValue01 == maxValue02) {
            return maxVuales01[1] - maxVuales02[1];
        } else {
            return maxValue01 - maxValue02;
        }

    }

    public static int[] judgeNumber02(String number) {
        String s = number.substring(3);
        int[] dpOfSer = new int[s.length()];
        int[] dpOfLin = new int[s.length()];
        boolean flag = true;
        dpOfSer[0] = 1;
        dpOfLin[0] = 1;
        for (int i = 1; i < s.length(); i++) {
            int d = s.charAt(i) - s.charAt(i - 1);
            if (d == 0) dpOfLin[i] = dpOfLin[i - 1] + 1;
            else dpOfLin[i] = 1;

            if (d == 1) {
                if (flag) {
                    dpOfSer[i] = dpOfSer[i - 1] + 1;
                } else {
                    dpOfSer[i] = 2;
                    flag = true;
                }
            }
            else if (d == -1) {
                if (!flag) {
                    dpOfSer[i] = dpOfSer[i - 1] + 1;
                } else {
                    dpOfSer[i] = 2;
                    flag = false;
                }
            }
            else dpOfSer[i] = 1;
        }

        int maxOfSer = 0;
        int maxOfLin = 0;

        for (int i = 0; i < dpOfLin.length; i++) {
            maxOfLin = Math.max(maxOfLin,dpOfLin[i]);
        }
        for (int i = 0; i < dpOfSer.length; i++) {
            maxOfSer = Math.max(maxOfSer,dpOfSer[i]);
        }

        return new int[]{maxOfSer,maxOfLin};
    }

    public static int judgeNumber(String number) {
        String s = number.substring(3);
        int[] dpOfSer = new int[s.length()];
        int[] dpOfLin = new int[s.length()];
        boolean flag = true;
        dpOfSer[0] = 1;
        dpOfLin[0] = 1;
        for (int i = 1; i < s.length(); i++) {
            int d = s.charAt(i) - s.charAt(i - 1);
            if (d == 0) dpOfLin[i] = dpOfLin[i - 1] + 1;
            else dpOfLin[i] = 1;

            if (d == 1) {
                if (flag) {
                    dpOfSer[i] = dpOfSer[i - 1] + 1;
                } else {
                    dpOfSer[i] = 2;
                    flag = true;
                }
            }
            else if (d == -1) {
                if (!flag) {
                    dpOfSer[i] = dpOfSer[i - 1] + 1;
                } else {
                    dpOfSer[i] = 2;
                    flag = false;
                }
            }
            else dpOfSer[i] = 1;
        }

        int maxOfSer = 0;
        int maxOfLin = 0;

        for (int i = 0; i < dpOfLin.length; i++) {
            maxOfLin = Math.max(maxOfLin,dpOfLin[i]);
        }
        for (int i = 0; i < dpOfSer.length; i++) {
            maxOfSer = Math.max(maxOfSer,dpOfSer[i]);
        }

        return Math.max(maxOfLin,maxOfSer);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] phoneNumbers = s.split(",");

        List<String> goodNumbers = new ArrayList<>();

        for (int i = 0; i < phoneNumbers.length; i++) {
            if (judgeNumber(phoneNumbers[i]) > 2) {
                // System.out.println(judgeNumber(phoneNumbers[i]) + " " +phoneNumbers[i]);
                goodNumbers.add(phoneNumbers[i]);
            }
        }
        if (goodNumbers.size() == 0) {
            System.out.println("null");
            return;
        }

        goodNumbers.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return compareNumber(o2,o1);
            }
        });

        for (int i = 0; i < goodNumbers.size(); i++) {
            if (i == goodNumbers.size() - 1) System.out.print(goodNumbers.get(i));
            else System.out.print(goodNumbers.get(i) + ",");
        }

    }

}
